@extends('shop::layouts.master')
@section('title')
    {{$title}}
@endsection
<style>
    .upload-button{
        background-image:url(admin/images/upimg.png);
        height:100px;width: 150px;border: 0;position: absolute;
    }
    .close{
        position: relative; top: -45px; right: 10px; border-radius: 50%; background-color: #FFFFFF;color: #FFF; opacity:0.1;
    }
    .img-list:hover .close
    {
        opacity:1; background-color: red;
    }

</style>
@section('tab')
    <div class="layui-fluid">
        <div class="layui-row">
            <form class="layui-form">

                <input type="hidden" name="id" value="{{$detail['id']}}">
                <div class="layui-form-item"> </div>

                <div class="layui-form-item">
                    <label for="L_alias" class="layui-form-label">
                        <span class="x-red">*</span>维修店名称</label>
                    <div class="layui-input-inline"style="width: 588px;">
                        <input type="text" name="name" this-id="{{$detail['id']}}" value="{{$detail['name']}}" lay-verify="required" @if($detail['admin_id'] != 1) @endif autocomplete="off" class="layui-input edit-shop">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="L_alias" class="layui-form-label">
                        <span class="x-red">*</span>联系方式</label>
                    <div class="layui-input-inline"style="width: 588px;">
                        <input type="text" name="phone" this-id="{{$detail['id']}}" value="{{$detail['phone']}}" lay-verify="phone" @if($detail['admin_id'] != 1) @endif autocomplete="off" class="layui-input edit-shop">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label for="L_alias" class="layui-form-label">
                            <span class="x-red">*</span>营业时间</label>
                        <div class="layui-input-inline">
                            <input type="text" name="start_time" value="{{$detail['start_time']}}" id="start" placeholder="上班时间" lay-verify="required" readonly="readonly" class="layui-input">
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" name="end_time" value="{{$detail['end_time']}}"  id="end" placeholder="下班时间" lay-verify="required" readonly="readonly" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_alias" class="layui-form-label">
                        <span class="x-red">*</span>公司log</label>
                    <div class="layui-input-inline">
                        @if($detail['logo']['full_src'])
                            <img class="layui-upload-img upload_img" src="{{$detail['logo']['full_src']}}" height="100" width="150">
                        @else
                            <img class="layui-upload-img upload_img" src="admin/images/upimg.png" height="100" width="150">
                        @endif
                        <input type="hidden" name="logo" value="" lay-verify="pic_log" id="img_url">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="L_alias" class="layui-form-label"><span class="x-red">*</span>轮播图</label>
                    <div class="layui-input-inline" style="width:80%; height: 118px;">
                        <div class="layui-upload-list">
                            @if(!empty($detail['shop_img']))
                                <input type="hidden" value="1" class="img_num" lay-verify="img_num">
                                @foreach($detail['shop_img'] as $i => $img)
                                <span class="img-list">
                                    <img src="{{$img['img']['full_src']}}" height="100" width="150" class="imgNum">
                                    <input type="hidden" name="img[{{$i}}]" value="{{$img['img']['src']}}">
                                    <i class="layui-icon close">ဆ</i>
                                </span>
                                @endforeach
                            @endif
                            <button type="button" class="upload-button" id="up_banner"></button>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="L_alias" class="layui-form-label">
                        <span class="x-red">*</span>所在城市</label>
                    <div class="layui-input-inline">
                        <select name="province" lay-verify="required" lay-filter="province">
                            <option value="">请选择</option>
                            @foreach($province as $p => $pr)
                                <option value="{{$p}}" @if($detail['province']==$p) selected @endif>{{$pr}}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="layui-input-inline">
                        <select name="city" lay-verify="required" lay-filter="city" id="city">
                            <option value="">请选择</option>
                            @foreach($city as $c => $ci)
                                <option value="{{$c}}" @if($detail['city']==$c) selected @endif>{{$ci}}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="layui-input-inline">
                        <select name="area" lay-verify="required" lay-filter="area" id="area">
                            <option value="">请选择</option>
                            @foreach($area as $a => $ar)
                                <option value="{{$a}}" @if($detail['area']==$a) selected @endif>{{$ar}}</option>
                            @endforeach
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="L_alias" class="layui-form-label">
                        <span class="x-red">*</span>详细地址</label>
                    <div class="layui-input-inline" style="width: 588px;">
                        <input type="text" name="address" value="{{$detail['address']}}" placeholder="街道" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label for="L_alias" class="layui-form-label">
                            <span class="x-red">*</span>经纬度</label>
                        <div class="layui-input-inline" >
                            <input type="text" name="longitude" value="{{$detail['longitude']}}" id="longitude" class="layui-input">
                        </div>
                        <div class="layui-input-inline" >
                            <input type="text" name="latitude" value="{{$detail['latitude']}}" id="latitude" class="layui-input">
                        </div>
                        <a class="layui-btn layui-btn-primary layui-btn-xs" id="parentIframe"> 拾取坐标 </a>
                    </div>
                </div>



                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label for="L_alias" class="layui-form-label">
                            <span class="x-red">*</span>运费设置</label>
                        <div class="layui-input-inline">
                            <input type="hidden" id ='is_delivery' value="{{$detail['delivery']}}">
                            <input type="radio" name="delivery" value="1" title="开启" lay-filter="delivery" @if($detail['delivery']==1) checked @endif class="layui-input">
                            <input type="radio" name="delivery" value="2" title="关闭" lay-filter="delivery" @if($detail['delivery']==2) checked @endif class="layui-input">
                        </div>
                        <span class="price">
                        <div class="layui-input-inline">
                            <input type="text" name="delivery_price" value="{{$detail['delivery_price']}}" placeholder="运费价格" class="layui-input yun">
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" name="order_price" value="{{$detail['order_price']}}" placeholder="订单满**元免运费"  class="layui-input mian">
                        </div>
                        </span>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label"></label>
                    <button class="layui-btn" lay-filter="add" lay-submit="">提交</button>
                </div>
            </form>
        </div>
    </div>

@endsection

@section('tab_js')
    @include('shop::author.this_js')
    <script>
        layui.use(['form', 'layer', 'jquery', 'upload', 'laydate'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer,
                upload = layui.upload;
            var laydate = layui.laydate;

            laydate.render({
                    elem: '#start'
                    ,type: 'time'
                    ,done: function(value){
                        var end = $('#end').val();
                        if (end && value > end) {
                            layer.msg('上班时间必须小于下班时间');
                            $('#start').val('');
                        };
                    }
                });
            laydate.render({
                elem: '#end'
                ,type: 'time'
                ,done: function(value){
                    var start = $('#start').val();
                    if (start && value < start) {
                        layer.msg('下班时间必须大于上班时间');
                        $('#end').val('');
                    };
                }
            });

            form.render();
            form.on('radio(delivery)', function(data){
                isdelivery(data.value);
            });

            isdelivery($('#is_delivery').val());

            function isdelivery(val){
                if(val == 1){
                    $('.yun').attr('lay-verify','required|number');
                    $('.mian').attr('lay-verify','required|number');
                    $('.price').show();
                }else{
                    $('.yun').attr('lay-verify','');
                    $('.mian').attr('lay-verify','');
                    $('.price').hide();
                }
            }
            form.verify({
                img_num : function(value) {
                    if (value <= 0) {
                        return '请上传轮播图';
                    }
                },
            });
            //监听提交
            form.on('submit(add)', function (data) {
                $.ajax({
                    url: 'shop-author-repairUpdate',
                    type: 'post',
                    data: data.field,
                    dataType: "json",
                    success: function (result) {
                        if (result.state === 0) {
                            layer.msg(result.msg, {time: 600, icon: 6});
                        } else {
                            layer.msg(result.msg, {time: 600, icon: 5});
                        }
                    }
                });
                return false;

            });
        });
    </script>
@endsection




